package com.hospital.yygh.hosp.controller;

import com.hospital.yygh.common.result.Result;
import com.hospital.yygh.hosp.service.DepartmentService;
import com.hospital.yygh.vo.hosp.DepartmentVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "科室列表")
@RestController
@RequestMapping("/admin/hosp/department")
//@CrossOrigin 因为使用了spring-gateway网关替代了Nginx，所以这里需要注释掉，不需要了
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    /**
     * 查询所有科室列表(根据医院编号，查询所有科室列表)
     *
     * @param hoscode
     * @return
     */
    @ApiOperation("查询所有科室列表")
    @GetMapping("getDepList/{hoscode}")
    public Result getDepList(@PathVariable("hoscode") String hoscode) {
        // 大科室下面还有小科室，不止一个科室，所以将返回数据封装在DepartmentVo
        List<DepartmentVo> list = departmentService.findDepTree(hoscode);
        return Result.ok(list);
    }


}
